import { defHttp } from '@/utils/http/axios';
import { ErrorMessageMode } from '#/axios';
import { BaseResponse} from '@/api/base';

// 定义接口地址
enum Api {
  /** 生成api.ts */
  API_TS = '/toolkit/genVben/apiTs',
  /** 获取所有的 Controller */
  CONTROLLER_LIST = '/toolkit/genVben/controller/list',
}

// 定义参数类型

export interface ControllerQuery {
  module?: String;
  name?: String;
  description?: String;
}

export interface ControllerVO {
  moduleName?: String;
  canonicalName?: String;
  requestUri?: String;
  simpleName?: String;
  description?: String;
}

export interface GenApiTsRequest {
  canonicalName?: String;
}

// 定义接口方法: save
// 生成api.ts
export function apiTs(params: GenApiTsRequest, mode: ErrorMessageMode = 'message') {
  return defHttp.post<BaseResponse<boolean>>(
    {
      url: Api.API_TS,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// 获取所有的 Controller
export function controllerList(params: ControllerQuery, mode: ErrorMessageMode = 'message') {
  return defHttp.post<BaseResponse<Array<ControllerVO>>>(
    {
      url: Api.CONTROLLER_LIST,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

